// pages/collect/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabs: [{
      id: 0,
      name: "商品收藏",
      isActive: true
      },{
      id: 1,
      name: "品牌收藏",
      isActive: false
      },{
      id: 2,
      name: "店铺收藏",
      isActive: false
      },{
        id: 3,
        name: "浏览足迹",
        isActive: false
      }
    ],
    collection: []
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    const collection = wx.getStorageSync("collection") || [];
    this.setData({collection});
  },

  /** 
   * 处理点击标题栏时，根据不同标题的索引加载不同的主体内容
   */
  handleItemTap(e) {
    const {index} = e.detail;
    let tabs = this.data.tabs;
    tabs.forEach(v => {
      v.id === index ? v.isActive = true : v.isActive = false;
    })
    this.setData({
      tabs: tabs
    })
  }


})